import request from '@/utils/request'

// 查询新闻公告列表
export function listNews(query) {
  return request({
    url: '/cms/news/list',
    method: 'get',
    params: query
  })
}

// 查询新闻公告详细
export function getNews(newsId) {
  return request({
    url: '/cms/news/' + newsId,
    method: 'get'
  })
}

// 新增新闻公告
export function addNews(data) {
  return request({
    url: '/cms/news',
    method: 'post',
    data: data
  })
}

// 修改新闻公告
export function updateNews(data) {
  return request({
    url: '/cms/news',
    method: 'put',
    data: data
  })
}

// 删除新闻公告
export function delNews(newsId) {
  return request({
    url: '/cms/news/' + newsId,
    method: 'delete'
  })
}

// 强制删除新闻公告
export function forceDelNews(newsId) {
  return request({
    url: '/cms/news/forceRemove/' + newsId,
    method: 'delete'
  })
}

// 发布新闻公告
export function pubNews(newsId) {
  return request({
    url: '/cms/news/pub/' + newsId,
    method: 'post',
  })
}

// 还原新闻公告
export function rebackNews(newsId) {
  return request({
    url: '/cms/news/reback/' + newsId,
    method: 'post',
  })
}

// 新闻公告转草稿
export function draftNews(newsId) {
  return request({
    url: '/cms/news/draft/' + newsId,
    method: 'post',
  })
}

// 查询新闻公告详细
export function getNewsOpen(newsId) {
  return request({
    url: '/open/cms/news/' + newsId,
    method: 'get'
  })
}

// 生成二维码
export function genNewsQrcode(newsId) {
  return request({
    url: '/cms/news/genQrCode/' + newsId,
    method: 'post'
  })
}
